<template>
	<view class="container">
		<view class="title">我们的产品</view>
		<view class="product-list">
			<view v-for="(product, idx) in products" :key="product.id" class="product-item" :class="{ reverse: idx % 2 === 1 }">
				<image :src="product.img" class="product-img" mode="aspectFill" @click="showEnlarge(idx)" />
				<view class="product-info">
					<view class="product-name">{{ product.name }}</view>
					<view class="product-desc">{{ product.desc }}</view>
				</view>
			</view>
		</view>
		<!-- 放大图片遮罩层 -->
		<view v-if="enlargedIdx !== -1" class="enlarge-mask" @click="closeEnlarge">
			<image :src="products[enlargedIdx].img" class="enlarge-img" mode="aspectFit" @click.stop="closeEnlarge" />
		</view>
	</view>
</template>

<script>
const products = [
	{ id: 1, name: '山寺桃花', desc: '鲜牛奶、茉莉绿茶、粉桃糯米', img: '/static/products/山寺桃花.png' },	{ id: 2, name: '蟾宫折桂', desc: '鲜牛奶、桂花乌龙、凤梨麻薯', img: '/static/products/蟾宫折桂.png' },	{ id: 3, name: '狐灵仙草', desc: '仙草冻、坚果、鲜牛奶、红茶', img: '/static/products/狐灵仙草.png' },	{ id: 4, name: '宇治抹茶', desc: '乌龙茶底，芝士奶盖', img: '/static/products/宇治抹茶.png' },	{ id: 5, name: '港式冻柠茶', desc: '鲜柠檬、红茶', img: '/static/products/港式冻柠茶.png' },	{ id: 6, name: '茉香爆柠', desc: '香水柠檬、茉莉绿茶', img: '/static/products/茉香爆柠.png' }
];
export default {
	data() {
		return {
			products,
			enlargedIdx: -1
		};
	},
	methods: {
		showEnlarge(idx) {
			this.enlargedIdx = idx;
		},
		closeEnlarge() {
			this.enlargedIdx = -1;
		}
	}
};
</script>

<style scoped>
.container {
	padding: 32rpx;
}
.title {
	font-size: 40rpx;
	font-weight: bold;
	margin-bottom: 24rpx;
	text-align: center;
}
.product-list {
	display: flex;
	flex-direction: column;
	gap: 32rpx;
}
.product-item {
	display: flex;
	gap: 24rpx;
	background: #fff;
	border-radius: 24rpx;
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
	padding: 24rpx;
	align-items: center;
	transition: box-shadow 0.2s;
}
.product-item.reverse {
	flex-direction: row-reverse;
}
.product-img {
	width: 220rpx;
	height: 220rpx;
	border-radius: 24rpx;
	object-fit: cover;
	cursor: pointer;
}
.product-info {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 8rpx;
}
.product-name {
	font-size: 32rpx;
	font-weight: bold;
	color: #de9190;
}
.product-desc {
	font-size: 26rpx;
	color: #666;
}
.enlarge-mask {
	position: fixed;
	left: 0;
	top: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.7);
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
}
.enlarge-img {
	max-width: 80vw;
	max-height: 80vh;
	border-radius: 32rpx;
	box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.18);
	background: #fff;
}
</style>
